﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class Dbhelper
    {
       
        private static readonly string sqlString = "server=.; uid=SunBoy;pwd=010927; database=Blogs";

        public  static DataTable GetDataTable(string sql)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql,sqlString);
            DataTable table = new DataTable();
            adapter.Fill(table);
            return table;
        }
        public static int AddOrUpdateOrDelete(string sql)
        {
            SqlConnection connection = new SqlConnection(sqlString);
            using (SqlCommand command=new SqlCommand(sql,connection))
            {
                connection.Open();
                return command.ExecuteNonQuery();
            }
        }

        

    }
}
